﻿#pragma once

#include <QObject>

#include <qvector.h>
#include <qhash.h>

class FileWriter;
class FileReader;
class ScriptRunner;
class LogSaver;

class ScriptSaveLoader : public QObject
{
  Q_OBJECT

private:
  FileWriter* fileWriter = Q_NULLPTR;
  FileReader* fileReader = Q_NULLPTR;
  ScriptRunner* scriptRunner= Q_NULLPTR;
  LogSaver* logSaver = Q_NULLPTR;
  int accuracy = 4;
public:
  ScriptSaveLoader(QObject* parent = Q_NULLPTR);
  ~ScriptSaveLoader();
signals:
  void signal_loadScriptSuccessful(QString filePath);
  void signal_loadScriptFileFailed(QString filePath);
  void signal_saveScriptFileSuccessful(QString filePath);
  void signal_saveScriptFileFailed(QString filePath);
public:
  bool saveAsScriptFile(QString filepath);//另存为脚本文件
  bool loadScriptFile(QString filepath);//载入脚本文件
private slots:
  void slot_scriptFileData(QString filePath, QByteArray data);
  void slot_loadScriptFileFailed(QString filePath);
  void slot_saveScriptFileSuccessfule(QString filePath);
  void slot_saveScriptFileFailed(QString filePath);
  //geter and seter
public:
  FileWriter* getFileWriter();
  void setFileWriter(FileWriter* fileWriter);
  FileReader* getFileReader();
  void setFileReader(FileReader* fileReader);
  ScriptRunner* getScriptRunner();
  void setScriptRunner(ScriptRunner* scriptRunner);
  LogSaver* getLogSaver();
  void setLogSaver(LogSaver* logSaver);
  int getAccuracy();
  void setAccuracy(int accuracy);
};
